package com.xbk.seckill.stock.application.service;

import com.xbk.seckill.common.cache.model.SeckillBusinessCache;
import com.xbk.seckill.common.model.dto.SeckillStockDTO;
import com.xbk.seckill.common.model.message.TxMessage;
import com.xbk.seckill.stock.application.model.command.SeckillStockBucketWrapperCommand;
import com.xbk.seckill.stock.application.model.dto.SeckillStockBucketDTO;

/**
 * 商品库存服务
 *
 * @author xiexu
 * @date 2025/3/8 22:08
 */
public interface SeckillStockBucketService {

    /**
     * 编排库存分桶
     */
    void arrangeStockBuckets(Long userId, SeckillStockBucketWrapperCommand stockBucketWrapperCommand);

    /**
     * 获取库存分桶
     */
    SeckillStockBucketDTO getTotalStockBuckets(Long goodsId, Long version);

    /**
     * 获取商品的库存信息
     *
     * @param goodsId
     * @param version
     * @return
     */
    SeckillBusinessCache<Integer> getAvailableStock(Long goodsId, Long version);

    /**
     * 扣减商品库存
     *
     * @param goodsId
     * @param version
     * @return
     */
    SeckillBusinessCache<SeckillStockDTO> getSeckillStock(Long goodsId, Long version);

    /**
     * 扣减商品库存
     */
    boolean decreaseStock(TxMessage txMessage);
}
